#CC=g++ -pg -g
CC=g++ -Wall -g -D DEBUG
CFLAGS=-O3 -funroll-loops -c
LDFLAGS=-O2 -lm
OBJSOURCES=Bfs.cc Bot.cc Bug.cc Map.cc Order.cc State.cc MI5.cc Strategy.cc Torus.cc Planif.cc
EXESOURCES=MyBot.cc
SOURCES=$(OBJSOURCES) $(EXESOURCES)
HEADERS=Bfs.hh Bot.h Bug.h group_by.hh Map.hh Order.hh munkres.h matrix.h Square.hh State.h MI5.hh Strategy.hh Timer.h Torus.hh Planif.hh
SUBMIT=Makefile ${SOURCES} ${HEADERS}
OBJECTS=$(OBJSOURCES:.cc=.o)
XOBJECTS=$(EXESOURCES:.cc=.o)
EXECUTABLE=MyBot
TESTS=Torus_ut Planif_ut example

#Uncomment the following to enable debugging
#CFLAGS+=-g -DDEBUG

all: $(OBJECTS) $(XOBJECTS) munkres.o $(EXECUTABLE)

tests: Torus_ut Planif_ut

$(EXECUTABLE): $(OBJECTS) $(XOBJECTS)
	$(CC) $(LDFLAGS) $(OBJECTS) $(XOBJECTS) munkres.o -o $@

Torus_ut: Torus_ut.cc $(OBJECTS) munkres.o
	$(CC) $(LDFLAGS) $^ -o $@

Planif_ut: Planif_ut.cc $(OBJECTS) munkres.o 
	$(CC) $(LDLAGS) $^ -o $@

example: main.cpp munkres.o
	$(CC) $(LDLAGS) $^ munkres.o -o $@


# no DEBUG mode for munkres
munkres.o: munkres.cpp
	g++ -Wall $(CFLAGS) $< -o $@	

.cc.o:
	$(CC) $(CFLAGS) $< -o $@

.cpp.o:
	$(CC) $(CFLAGS) $< -o $@


%: %.cc $(OBJECTS)
	$(CC) $(LDLAGS) $< -o $@

clean: 
	-rm -f ${EXECUTABLE} ${OBJECTS} *.d
	-rm -f debug.txt
	-rm -f *.o
	-rm -f *~
	-rm -f debug_*.txt
	-rm -f ${TESTS}


zip: clean
	-rm -f *.zip
	zip search_and_destroy.zip 



.POHNY: all clean zip


